<?php
  require("./config.php");
  
  $query = "SELECT identifiant, motdepass FROM ";    

  $login_in=$_POST['login'] ;
  $password_in=$_POST['password'] ;
  $compte=$_POST['compte'];
  
  
  if($compte=="stagiaire") {
    $query .="stagiaire where identifiant='$login_in' and motdepass='$password_in'";
	// echo "".$query;
    if($result = mysql_query($query)) 
	{
		  if(mysql_fetch_array($result)) {               
            
			session_start (); 
			$_SESSION['login'] =	$login_in  ;
			$_SESSION['ident'] =	$compte;  
			header('Location: ../Prive/Stagiaires/page_stagiare.php ');			
          }
		  else
		  header('Location: index.php?msg=" Login et/ou le mot de passe non valid   !!!"');    
		  
    } 
  }
  else if($compte=="societe"){
    $query .="entreprise where identifiant='$login_in' and motdepass='$password_in'";
	// echo "".$query;
    if($result = mysql_query($query)) 
	{
		 if(mysql_fetch_array($result))
		{
			session_start (); 
			$_SESSION['login'] =	$login_in  ;
			$_SESSION['ident'] =	$compte;
			header('Location: ../Prive/Entreprises/page_societe.php '); 			
        }
		else
		header('Location: index.php?msg=" Login et/ou le mot de passe non valid  !!!"');    
  }
  }
  else if($compte=="owner"){
     $query .="admin where identifiant='$login_in' and motdepass='$password_in'";
	// echo "".$query;
    if($result = mysql_query($query)) 
	{
		if(mysql_fetch_array($result)) 
		 {
			session_start (); 
			$_SESSION['login'] =	$login_in  ;
			$_SESSION['ident'] =	$compte;
			header('Location:   page_admin.php ');		
         }
		else
		header('Location: index.php?msg=" Login et/ou le mot de passe non valid  !!!"');    
    } 
  
  }        
  else
  {      
    //retour vers le formulaire avec accompagne du message d'erreur 
    header('Location: index_gestion.php?msg=" Identifiez vous !!!"');      
  }   



?>